//
//  ProjectDetailController.m
//  MyTrip
//
//  Created by zhang on 15/8/26.
//  Copyright (c) 2015年 张益. All rights reserved.
//

#import "ProjectDetailController.h"
#import "Project.h"
#import "MBProgressHUD.h"

@interface ProjectDetailController ()<UIWebViewDelegate>

@property (nonatomic, retain) UIWebView *web;
@property (nonatomic, retain) MBProgressHUD *hud;


@end

@implementation ProjectDetailController


- (void)dealloc
{
    self.web.delegate = nil;
    [_web retain];
    [_project release];
    [super dealloc];
}


- (void)createWeb{
    
    self.web = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height + 64)] autorelease];
    [self.view addSubview:_web];
    _web.delegate = self;
    [_web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_project.url]]];
    
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:70 / 255.0f green:160 / 255.0f blue:175 / 255.0f alpha:1];
    
    [self createWeb];
}


- (void)webViewDidStartLoad:(UIWebView *)webView{
    self.hud = [[MBProgressHUD alloc] init];
    [self.view addSubview:_hud];
    [_hud show:YES];
    _hud.labelText = @"正在拼命加载......";
    UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, -64 * OffHeight, self.view.frame.size.width, self.view.frame.size.height + 64 * OffHeight)] autorelease];
    [view setBackgroundColor:[UIColor blackColor]];
    [self.navigationController.navigationBar addSubview:view];
    [view setTag:10];
    [view setAlpha:0.1];
    
    //    在网络请求之后
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    UIView *view = (UIView *)[self.navigationController.navigationBar viewWithTag:10];
    NSLog(@"%@", view);
    [view removeFromSuperview];
    
    _hud.hidden = YES;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
